Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix eslint warnimg #3709

Merged
merged 3 commits into from
Aug 20, 2022
Merged

Conversation

lumburr
Copy link
Contributor

@lumburr lumburr commented Apr 2, 2022

What: fix #3224

Why:

How:

Use a new utils function replace v == null to fix eslint warning.
It's a code style issue. We also can chage ESlint config option "no-eq-null" to fix it. Which plan are we going to take? I will update my pr if it needs to change.

Checklist:

  • Documentation N/A
  • Added/updated unit tests N/A
  • Code complete

@matthew-dean
Copy link
Member

matthew-dean commented Apr 21, 2022

So, I don't agree with this approach. I think the better way is to figure out what foo == null was intended to check for. If it's just checking for a "falsey" value, it should just be !foo.

That is, someone should log all these cases of == null with a typeof during testing to see what exactly are the types of values getting loosely checked against null, and then re-write this in a way that is more clear. That's IMO a better approach rather than just adding a bunch of function wrappers, which possibly degrades performance.

@lumburr lumburr changed the title Update e slint and fix warnimg Update eslint and fix warnimg Apr 26, 2022
@lumburr lumburr marked this pull request as draft April 26, 2022 12:41
@lumburr
Copy link
Contributor Author

lumburr commented Apr 27, 2022

  1. Conclusion: currentDirectory---- is related to the file, there are only two possible undefined, normal value
    currentDirectory comes from the file information in the node and will be given a default value of {}.
    Path: packages/less/src/less/environment/environment.js
    1
    Path: packages/less/src/ess/tree/node.js
    1-2
  2. Conclusion: v has three possible values null, undefined, normal.
    Path: packages/less/src/less/functions/default.js
    2
  3. Conclusion: unit has only two possible values null, normal value.
    Path: packages/less/src/less/functions/math-helper.js
    3
    MathHelper is only used in two places.
    Path: packages/less/src/less/functions/math.js
    3-2
    It is normal.
    Path: packages/less/src/less/functions/number.js
    3-3
    It is normal or null.
  4. Conclusion: value.value has only two possible values undefined, normal value.
    Path: packages/less/src/less/parser/paser.js
    4
    Path: packages/less/src/less/parser/paser.js
    4-1
    It is normal or undefind.
    Path: packages/less/src/less/parser/paser.js
    4-2
    It is undefind.
    Path: packages/less/src/less/parser/paser.js
    4-3
    It is undefind.
    Path: packages/less/src/less/parser/paser.js
    4-4
    It is normal or undefind.
  5. Conclusion: this.visibilityBlocks has only two possible values undefined, normal value
    Path: packages/less/src/less/tree/node.js
    5
    Default value is undefind, Invalid information is filtered.
  6. Conclusion: escaped has two possible values, boolean value, default value undefined
    Path: packages/less/src/less/tree/quoted.js
    6
    Path: packages/less/src/less/parser/parser.js
    6-1
    It is undefind.
    Path: packages/less/src/less/parser/parser.js
    6-2
    It is undefind or boolean.
  7. Conclusion: nestedSelector has only two possible values null, normal value.
    Path: packages/less/src/less/tree/ruleset.js
    7
    Path: packages/less/src/less/tree/ruleset.js
    7-1
    nestedSelector instanceof Selector or return null.
  8. Conclusion: evaldCondition has three possible values null, undefined, normal.
    Path: packages/less/src/less/tree/selector.js
    8
    Path: packages/less/src/less/tree/ruleset.js
    8-1
    It is undefind.
    Path: packages/less/src/less/tree/atrule.js
    8-2
    It is null.

@lumburr lumburr marked this pull request as ready for review April 27, 2022 11:26
@lumburr lumburr changed the title Update eslint and fix warnimg Fix eslint warnimg Apr 27, 2022
@matthew-dean
Copy link
Member

Thanks for doing this research!

@matthew-dean matthew-dean merged commit 721659e into less:master Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Maintenance Task] - Review ESLint settings and fix linting issues
2 participants